#include "named_pipe.hpp"

void ReadMessage(NamedPipe &fifo)
{
    while (true)
    {
        std::string message;
        int n = fifo.ReadNamePipe(&message);
        if (n > 0)
        {
            std::cout << "Client Say> " << message << std::endl;
        }
        else if (n == 0)
        {
            std::cout << "Client Quit, Server Too" << std::endl;
            break;
        }
        else
        {
            std::cout << "fifo.ReadNamePipe Error" << std::endl;
            break;
        }
    }
}

// read
int main()
{
    NamedPipe fifo(comm_path, Creater);
    if (fifo.OPenForRead())
    {
        // 读文件
        ReadMessage(fifo);
    }
    return 0;
}